import { type App } from 'vue'
import { createRouter, createWebHashHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'

import order from '../views/demo/list/index.vue'
import layout from '@/layout/index.vue'
const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'index',
    redirect: 'admin',
  },
  {
    path: '/admin',
    name: 'admin',
    component: layout,
    children: [
      {
        path: '/demo',
        name: 'demo',
        component: order,
      },
    ],
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

const initRouter = (app: App<Element>) => {
  app.use(router)
}

export { initRouter }

// export default router
